package com.mysterymall.Controller;

import com.mysterymall.Common.Comp.Log;
import com.mysterymall.Common.Utils.Result;
import com.mysterymall.Model.Entity.BankCard;
import com.mysterymall.Service.BankCardService;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName com.mysterymall.Controller
 * @Description
 * @Author HuangWX
 * @Time 2023/12/13  15:48
 */
@RestController
@RequestMapping("/bankCard")
public class BankCardController {


    private final BankCardService bankCardService;

    /**
     * 构造器注入
     * @param bankCardService 银行卡服务
     */
    public BankCardController(BankCardService bankCardService) {
        this.bankCardService = bankCardService;
    }

    /**
     * 添加银行卡
     * @param bankCard 银行卡实体
     * @return Result
     */
    @PostMapping("/addBankCard")
    public Result addBankCard(@RequestBody BankCard bankCard){
        return bankCardService.addBankCard(bankCard);
    }

    /**
     * 添加银行卡
     * @param bankCard 银行卡实体
     * @return Result
     */
    @PostMapping("/addBankCardAdmin")
    public Result addBankCardAdmin(@RequestBody BankCard bankCard){
        return bankCardService.addBankCardAdmin(bankCard);
    }

    /**
     * 删除银行卡
     * @param bankCardId 银行卡实体Id
     * @return Result
     */
    @GetMapping("/deleteBankCard")
    public Result deleteBankCard(@RequestParam("id") String  bankCardId){
        return bankCardService.deleteBankCard(bankCardId);
    }

    /**
     * 修改银行卡
     * @param bankCard 银行卡实体
     * @return Result
     */
    @PostMapping("/updateBankCard")
    public Result updateBankCard(@RequestBody BankCard bankCard){
        return bankCardService.updateBankCard(bankCard);
    }

    /**
     * 修改银行卡
     * @param bankCard 银行卡实体
     * @return Result
     */
    @PostMapping("/updateBankCardAdmin")
    public Result updateBankCardAdmin(@RequestBody BankCard bankCard){
        return bankCardService.updateBankCardAdmin(bankCard);
    }

    /**
     * 查询银行卡
     * @return Result
     */
    @PostMapping("/getBankCard")
    public Result getBankCard(){
        return bankCardService.getBankCard();
    }

    @GetMapping ("/getBankCardById")
    @Log
    public Result getBankCardById(@RequestParam("id")String bankCardId){
        return bankCardService.getBankCardById(bankCardId);
    }

    @GetMapping ("/getBankCardByIdAdmin")
    @Log
    public Result getBankCardByIdAdmin(@RequestParam("id")String bankCardId){
        return bankCardService.getBankCardByIdAdmin(bankCardId);
    }


    @GetMapping("/getMyBankCard")
    @Log
    public Result getMyBankCard(){
        return bankCardService.getMyBankCard();
    }
}
